
import { menulist } from '../../api/api'
const state = {
  menuList: []
}

// 类似于计算属性 对state力度数据进行处理返回
const getters = {
  // 函数形式
  getMenuData (state) {
    return state.menuList
  }
}
const mutations = {
  REQ_MENULIST (state, payload) {
    state.menuList = payload
  }
}
const actions = {
// 如果想修改state的数据 通过调用mutations里的commit方法
// 调取 菜单列表
  getMeulist ({ commit }) {
    menulist({ istree: true }).then(res => {
      if (res.code === 200) {
        console.log(res)
        commit('REQ_MENULIST', res.list)
      } else {
        alert(res.msg)
      }
    })
  }

}

export default {
  namespaced: true,
  state,
  getters,
  mutations,
  actions
}
